<template>
  <el-carousel :interval="4000" type="card" height="380px">
    <el-carousel-item v-for="(item, index) in carouselImages" :key="index">
      <img :src="item.url" alt="轮播图片" class="carousel-img">
    </el-carousel-item>
  </el-carousel>
</template>

<script setup>
import { ref } from 'vue'

// 导入本地图片
import img1 from '../assets/images/slide1.jpg'
import img2 from '@/assets/images/slide2.jpg'
import img3 from '@/assets/images/slide3.jpg'
import img4 from '@/assets/images/slide4.jpg'
import img5 from '@/assets/images/slide5.jpg'
import img6 from '@/assets/images/slide6.jpg'

// 定义轮播图片数组
const carouselImages = ref([
  { url: img1, alt: '轮播图片1' },
  { url: img2, alt: '轮播图片2' },
  { url: img3, alt: '轮播图片3' },
  { url: img4, alt: '轮播图片4' },
  { url: img5, alt: '轮播图片5' },
  { url: img6, alt: '轮播图片6' }
])
</script>

<style scoped>
/* 设置图片样式 */
.carousel-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* 保持图片比例，覆盖容器 */
}

/* 保持原有的轮播项样式 */
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>